﻿Imports System.Data.OracleClient

Namespace persistent

    Public Class CXException

        Private Shared ConnStr As String = GlobalVar.OraConnStr

        Private Shared dbPackageName As String = "eu_bill.CXException."

        Public Shared Function Exception_LOG(ByVal procedureInfo As String, ByVal request As String, ByVal message As String, ByVal error_code As String, ByVal error_message As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "Exception_LOG")
            command.Parameters.Add("procedureInfo", OracleType.VarChar).Value = procedureInfo
            command.Parameters.Add("request", OracleType.VarChar).Value = request
            command.Parameters.Add("message", OracleType.VarChar).Value = message
            command.Parameters.Add("pout_error_Code", OracleType.VarChar).Value = error_code
            command.Parameters.Add("pout_error_Message", OracleType.VarChar).Value = error_message
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function ExecuteNonQuery(ByVal command As OracleCommand, ByRef MESSAGE As String)
            Dim connection As New OracleConnection(ConnStr)
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure

            Try
                connection.Open()
                command.ExecuteNonQuery()
            Catch ex As Exception
                MESSAGE = ex.Message.ToString
            Finally
                connection.Close()
            End Try
        End Function
        Public Shared Function ExecuteDataTable(ByVal command As OracleCommand, Optional ByVal directSql As Boolean = 0) As DataTable
            Dim connection As New OracleConnection(ConnStr)
            Dim dataAdapter As New OracleDataAdapter(command)
            Dim dataTable As New DataTable
            Dim dataSet As New DataSet

            command.Connection = connection

            If Not (directSql) Then
                command.CommandType = CommandType.StoredProcedure
            End If

            Try
                connection.Open()
                dataAdapter.Fill(dataSet)
                dataTable = dataSet.Tables(0)
            Catch ex As Exception
            Finally
                connection.Close()
                dataSet.Dispose()
            End Try

            Return dataTable
        End Function


    End Class
End Namespace